Skip to content

Harness: start the tagged child a second later in AW's Process.Start reader-failure cases - #123

Merged
HalRiveria merged 10 commits into
mainfrom
test/aw-escape-window
Dec 3, 2026
Merged

HalRiveria merged 10 commits into
mainfrom
test/aw-escape-window

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong: the CI run on main after #119 failed one assertion under PowerShell 7, in the module step: "a program whose stderr reader can't start is ended and the start reported as failed, Process.Start (1 left running, ...)". On the Process.Start path a program runs before the kit adds it to its Job Object. So a child it starts straight away can start outside its tree job and survive the kill, the gap the README's Limits gives for AddedToJob mode. The test's program, cmd /d /c ping -n 30 -w <tag> ..., starts its ping at once, and a slow runner let the ping in ahead of the kit once. The test added in #115 ("a program that has exited when its reader fails ..., Process.Start") has the same race. It hasn't failed yet. Not a kit bug.

What changed: test-only. In both tests' Process.Start case, cmd.exe now waits about a second (ping -n 2) before starting the tagged ping, so the ping starts after cmd.exe is in its Job Object. The failing reader start is held with TestFailRunDelayMs (2.5 s, and 3.5 s where cmd.exe also has to exit first), so the ping is up when the rollback runs. The CreatedInJob and batch cases are unchanged: there the program is created inside its Job Object, so there's no gap.

One trade-off: nothing checks that the tagged ping was up when the rollback ran. A runner that stalled cmd.exe for over 2.5 s would pass without testing the child kill.

How it was tested: a race that failed once on CI can't be shown failing on demand. Section AW passes on both runtimes, and all 779 assertions of the full harness pass on Windows PowerShell 5.1 and on PowerShell 7.

The dispatcher checks for an abort once per pass, and its start loop read only the token, which that check cancels. So a Ctrl+C landing while the loop was starting programs, or a -JobStarter that requested an abort, still filled every free slot on that pass. The start loop now also reads the abort flag before each job, ahead of the shared budget's Wait(0) so no slot is taken for a job that won't start. Harness section O covers a -JobStarter that requests an abort, with a plain limit and with a shared budget.
The test that kills a live tree listed beside a disposed process counted leftover pings right after Stop-PkProcessTree returned. Ending a Job Object returns before Windows has finished tearing its processes down, so on a CI runner the ping was still listed once. It now waits up to 5 seconds for it to go, as the other kill tests do.
…Exit doesn't warn after the kit's own kill

With -KillTreeOnExit, a program the kit killed (for its time limit, Invoke-PkProcessWithTimeout's limit, or an abort's force-stop) got the warning that it "has no Job Object of its own". KillTree closed the program's tree job once it had ended it, so -KillTreeOnExit, ending it again once the program had exited, found no tree job.

KillTree now leaves the tree job open: a second KillTree ends an empty job and succeeds, quietly. Complete-PkProcess closes it as before, and so do the force-stop and Invoke-PkProcessWithTimeout's cleanup, which dispose a killed program without completing it. Harness section BJ covers the three kills; BF's check that a kill releases the tree job now expects the release at Complete-PkProcess, and a second KillTree to succeed.

The README's Limits also says a program whose path is over 260 characters can't be started: Windows refuses it, long paths enabled or not.
… every dispatcher kill test

On CI, 'a -JobFinalize that throws gets no -JobAbortCleanup for its finished job' failed under Windows PowerShell 5.1 with 1 ping left: it counted leftover pings right after the dispatcher's teardown kill, and ending a Job Object returns before Windows has torn its processes down. Five other tests count the same way. They now all use one helper, Get-LimitPingLeft, which waits up to 5 seconds for the pings to go, and still fails one that survives.
…reader-failure cases

On the Process.Start path a program runs before the kit adds it to its Job Object, so a child it starts straight away can start outside its tree job and survive the kill, the gap the README's Limits gives for AddedToJob. Two AW tests started their tagged ping straight away on that path, and on a slow CI runner one failed with the ping left running. On that path the ping now starts about a second later, after the program is in its Job Object, and the failing reader start waits until it's up.
@HalRiveria
HalRiveria merged commit 3e73c17 into main Dec 3, 2026
3 checks passed
@HalRiveria
HalRiveria deleted the test/aw-escape-window branch December 3, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants